package com.gjy.design.proxy.staticp;

import com.gjy.design.proxy.OrderService;

/**
 * @author gjy
 * @version 1.0
 * @since 2025-11-10 10:40:09
 */
public class OrderServiceLogProxy implements OrderService {
    private final OrderService delegate;

    public OrderServiceLogProxy(OrderService delegate) {
        this.delegate = delegate;
    }

    @Override
    public void createOrder(String productId, int quantity) {
        long start = System.currentTimeMillis();
        delegate.createOrder(productId, quantity);
        long end = System.currentTimeMillis();
        System.out.println("[LOG] createOrder cost: " + (end - start) + " ms");
    }

    @Override
    public void cancelOrder(String orderId) {
        long start = System.currentTimeMillis();
        delegate.cancelOrder(orderId);
        long end = System.currentTimeMillis();
        System.out.println("[LOG] cancelOrder cost: " + (end - start) + " ms");
    }
}

